<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="msg"></div>
  <script>
    const data={
      username:'张三',
      age:20
    }
    const proxy={};
    Object.entries(data).forEach(([key,value])=>{
      Object.defineProperty(proxy, key ,{
      get(){
        return value;
      },
      set(v){
        document.getElementById('msg').innerHTML=v;
         data[key]=v;
        return true;
      }
    })
  })
    
    document.getElementById('msg').innerHTML=proxy.username;

  </script>
</body>
</html>